<html>
<body>
<div id="ofc_barchart"></div>
<br />
<br />
<div id="ofc_piechart"></div>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF(
    "open-flash-chart.swf",
    "ofc_barchart",
    "350", "200",
    "9.0.0", "expressInstall.swf",
    {"data-file": "barchart.json"}
);
 
swfobject.embedSWF(
    "open-flash-chart.swf",
    "ofc_piechart",
    "350", "200",
    "9.0.0", "expressInstall.swf",
    {"data-file": "piechart.json"}
);
 
function ofc_onclick(index) {
        alert(index);
}
 
OFC = {};
 
OFC.none = {
    name: "pure DOM",
    version: function(src) { return document.getElementById(src).get_version() },
    rasterize: function (src, dst) {

      var _dst = document.getElementById(dst)
      e = document.createElement("div")
      e.innerHTML = Control.OFC.image(src)
      _dst.parentNode.replaceChild(e, _dst);
    },
    image: function(src) {
var cc = document.getElementById(src);
alert( cc.get_img_binary());
return "<img src='data:image/png;base64," + document.getElementById(src).get_img_binary() + "' />"},
    popup: function(src) {
        var img_win = window.open('', 'Charts: Export as Image')
        with(img_win.document) {
            write("<html><head><title>Charts: Export as Image<\/title><\/head><body>" + Control.OFC.image(src) + "<\/body><\/html>") }
     }
}
 
if (typeof(Control == "undefined")) {
        var Control = {OFC: OFC.none}
}
 
function save_image() {
 
        Control.OFC.popup('ofc_piechart')
 
}
 
</script>
</body>
</html>